package com.cqie.rbac.controller;


import com.cqie.rbac.bo.CourseBo;
import com.cqie.rbac.bo.DepartmentBo;
import com.cqie.rbac.entity.Course;
import com.cqie.rbac.entity.Department;
import com.cqie.rbac.entity.TestCourse;
import com.cqie.rbac.entity.TestDepartment;
import com.cqie.rbac.mapper.TestCourseMapper;
import com.cqie.rbac.mapper.TestDepartmentMapper;
import com.cqie.rbac.service.ICourseService;
import com.cqie.rbac.service.IDepartmentService;
import com.cqie.rbac.util.MyPageHelper;
import com.cqie.rbac.util.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 * 课程表 前端控制器
 * </p>
 *
 * @author 单机吧
 * @since 2021-10-11
 */
@Api(tags ="课程管理")
@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private ICourseService iCourseService;

    @Autowired
    private TestCourseMapper testCourseMapper;


    @ApiOperation("获取课程列表信息")
    @GetMapping("/getCourseList")
    public Result<PageInfo<Course>> GetCourseList(CourseBo bo){
        List<Course> list = iCourseService.pageOfCourse(bo);
        return Result.ok().data(MyPageHelper.returnPage(list));
    }
    @ApiOperation("新增课程")
    @PostMapping("/insertCourse")
    public Result InsertCourse(TestCourse testCourse){
        testCourseMapper.insert(testCourse);
        return Result.ok();
    }

    @ApiOperation("删除课程")
    @PostMapping("/deleteCourse")
    public Result DeleteCourse(Integer id){
        testCourseMapper.deleteByPrimaryKey(id);
        return Result.ok();
    }

    @ApiOperation("修改课程")
    @PostMapping("/updateCourse")
    public Result UpdateCouse(TestCourse testCourse){
        testCourseMapper.updateByPrimaryKeySelective(testCourse);
        return Result.ok();
    }


//    @ApiOperation("根据id查询学院")
//    @GetMapping("/getCourseNameById")
//    public Result GetCourseNameById(Long id){
//        Course course = iCourseService.GetCourseNameById(id);
//        return Result.ok().data(course);
//    }
//
//    @ApiOperation("编辑或修改学院信息")
//    @GetMapping("/updateOrAddMenu")
//    public Result UpdateOrAddMenu(@RequestBody DepartmentBo bo){
//        return iDepartmentService.UpdateOrAddMenu(bo);
//    }


}
